package com.hdaccp.user.controller;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.hdaccp.pojo.po.UserAddress;
import com.hdaccp.pojo.vo.UserAddressVo;
import com.hdaccp.user.dao.UserAddressDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/useraddress")
public class UserAddressController {
    @Autowired
    private UserAddressDao userAddressDao ;
    @RequestMapping("/getOne/{id}")
    public UserAddress getOne(@PathVariable("id") int addressid) {
        return userAddressDao.findById(addressid).get() ;
    }


    @RequestMapping("/getOneVo/{id}")
    public UserAddressVo getOneVo(@PathVariable("id") int addressid) {
        UserAddress userAddress = userAddressDao.findById(addressid).get();
        UserAddressVo vo = new UserAddressVo() ;
        vo.setAddress(userAddress.getAddress());
        vo.setCreateTime(userAddress.getCreateTime());
        vo.setId(userAddress.getId());
        vo.setIsDefault(userAddress.getIsDefault());
        vo.setRemark(userAddress.getRemark());
        return vo ;
    }

}
